#!/usr/bin/env python 
# -*- coding:utf-8 -*-
"""
@Time:2022/2/13 3:43 下午"
@Author:lydia_liu"
@File:wework.py
@function:
"""

from python.API.po_api2.apis import BaseApi


class Wework(BaseApi):

    def __init__(self,corpid,corpsecret):
        self.token = self.get_accesstoken(corpid,corpsecret)

    def get_accesstoken(self,corpid,corpsecrect):
        """获取access_token"""

        # corpid = 'wwd88ffb3cf55b0fc1'
        # corpsecrect = 'SjA8LhfEuDtXVFb-k1eRLOttxym5nnkLrL1W8je7XAI'

        # url = 'https://qyapi.weixin.qq.com/cgi-bin/gettoken'
        # params = {
        #     "corpid": corpid,
        #     "corpsecret": corpsecrect
        # }
        req = {
            "method":'GET',
            'url':'https://qyapi.weixin.qq.com/cgi-bin/gettoken',
            'params' :{
                "corpid": corpid,
                "corpsecret": corpsecrect
             }
        }
        r = self.send_api(req)
        # r = requests.request(url=url, method='GET', params=params)
        token = r.json()['access_token']

        return token